<?php

function dot($graph,$format){
    global $apm_graph_path,$apm_dot_path;
    $in=realpath($apm_graph_path.$graph.'.dot');
    $out=$in.'.'.$format;

    if( !file_exists($out) || filemtime ( $out )!=filemtime ( $in ) ){
          //redraw graph
          $cmd=$apm_dot_path.' -T'.$format.' '.escapeshellarg('-o'.$out).' '.escapeshellarg($in);
          //die($cmd);
          exec( $cmd );
          touch($out,filemtime ( $in ));
    }
    return $out;
}
